@extends('admin::layouts.master')
@section('content')
    <div class="col-lg-12">
        <div class="card card-flat">
            <div class="card-header">为角色[{{$role['title']}}]分配权限</div>
            <div class="card-body">
                <form action="/admin/addpermission/{{$role['id']}}" method="post">
                    @csrf
                    @foreach($permissions as $p)
                        @foreach($p['rules'] as $v)
                    <div class="form-group row pt-1 pb-1">
                        <label class="col-12 col-sm-3 col-form-label text-sm-right">{{$v['group']}}</label>
                        <div class="col-12 col-sm-8 col-lg-6 form-check mt-2">
                            @foreach($v['permissions'] as $vv)
                            <label class="custom-control custom-checkbox custom-control-inline">
                                <input type="checkbox" name="name[]" value="{{$vv['name']}}" class="custom-control-input" {{$role->hasPermissionTo($vv['name'])?'checked':''}}><span class="custom-control-label">{{$vv['title']}}</span>
                            </label>
                                @endforeach
                        </div>
                    </div>
                            @endforeach
                    @endforeach
                <button type="submit" class="btn btn-primary">保存</button>
                </form>
            </div>
        </div>
    </div>
@endsection